package com.example.ds.config;

import com.example.ds.filter.RequestTimeFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<RequestTimeFilter> requestTimeFilterRegistration(
            RequestTimeFilter filter) {
        
        FilterRegistrationBean<RequestTimeFilter> registration = 
                new FilterRegistrationBean<>(filter);
        
        // 设置过滤器顺序（数字越小优先级越高）
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);
        return registration;
    }
}